package com.aspose.cells;

import java.util.Iterator;

class ztc {
   private zok a = null;
   private Workbook b = null;

   ztc(zok var1) {
      this.a = var1;
      this.b = var1.a;
   }

   void a(zcfx var1) throws Exception {
      ExternalConnectionCollection var2 = this.b.getDataConnections();
      var1.b(true);
      if (var2 != null) {
         var1.b("connections");
         if (var2.b.length() > 0) {
            var1.a("xmlns", var2.b);
         }

         Iterator var3 = var2.iterator();

         while(var3.hasNext()) {
            ExternalConnection var4 = (ExternalConnection)var3.next();
            if (var4 instanceof DBConnection) {
               this.a(var4, var1);
            } else {
               var1.d(var4.A);
            }
         }

         var1.b();
      }

      var1.d();
      var1.e();
   }

   private void a(ExternalConnection var1, zcfx var2) throws Exception {
      var2.b("connection");
      var2.a("id", zase.y(var1.getConnectionId()));
      if (!this.a(var1.getSourceFile())) {
         var2.a("sourceFile", var1.getSourceFile());
      }

      if (!this.a(var1.getOdcFile())) {
         var2.a("odcFile", var1.getOdcFile());
      }

      if (var1.getKeepAlive()) {
         var2.a("keepAlive", "1");
      }

      if (var1.getRefreshInternal() != 0) {
         var2.a("interval", zase.y(var1.getRefreshInternal()));
      }

      if (!this.a(var1.getName())) {
         var2.a("name", var1.getName());
      }

      if (!this.a(var1.getConnectionDescription())) {
         var2.a("description", var1.getConnectionDescription());
      }

      int var3 = zuo.e(var1.getType());
      if (var3 != 255) {
         var2.a("type", zase.y(var3));
      }

      int var4 = zuo.c(var1.getReConnectionMethod());
      var2.a("reconnectionMethod", zase.y(var4));
      var2.a("refreshedVersion", zase.a(var1.b()));
      if (0 != var1.c()) {
         var2.a("minRefreshableVersion", zase.a(var1.c()));
      }

      if (var1.getSavePassword()) {
         var2.a("savePassword", "1");
      }

      if (var1.isNew()) {
         var2.a("new", "1");
      }

      if (var1.isDeleted()) {
         var2.a("deleted", "1");
      }

      if (var1.getOnlyUseConnectionFile()) {
         var2.a("onlyUseConnectionFile", "1");
      }

      if (var1.getBackgroundRefresh()) {
         var2.a("background", "1");
      }

      if (var1.getRefreshOnLoad()) {
         var2.a("refreshOnLoad", "1");
      }

      if (var1.getSaveData()) {
         var2.a("saveData", "1");
      }

      if (var1.getCredentials() != 0) {
         var2.a("credentials", zuo.a(var1.getCredentials()));
      }

      if (!this.a(var1.getSSOId())) {
         var2.a("singleSignOnId", var1.getSSOId());
      }

      if (var1 instanceof DBConnection) {
         this.a((DBConnection)var1, var2);
      } else if (var1 instanceof zaro) {
         this.a((zaro)var1, var2);
      } else if (var1 instanceof zbsr) {
         this.a((zbsr)var1, var2);
      } else if (var1 instanceof zbve) {
         this.a((zbve)var1, var2);
      } else {
         this.a((zbud)var1, var2);
      }

      if (var1.getParameters().getCount() > 0) {
         this.a(var1.getParameters(), var2);
      }

      if (!this.a(var1.d())) {
         var2.d(var1.d());
      }

      var2.b();
   }

   private void a(DBConnection var1, zcfx var2) throws Exception {
      var2.b("dbPr");
      if (!this.a(var1.getConnectionInfo())) {
         var2.a("connection", var1.getConnectionInfo());
      }

      if (!this.a(var1.getCommand())) {
         var2.a("command", var1.getCommand());
      }

      int var3 = zuo.i(var1.getCommandType());
      var2.a("commandType", zase.y(var3));
      if (!this.a(var1.a())) {
         var2.a("serverCommand", var1.a());
      }

      var2.b();
   }

   private void a(zaro var1, zcfx var2) {
   }

   private void a(zbsr var1, zcfx var2) {
   }

   private void a(zbve var1, zcfx var2) {
   }

   private void a(zbud var1, zcfx var2) {
   }

   private void a(ConnectionParameterCollection var1, zcfx var2) throws Exception {
      int var3 = var1.getCount();
      var2.b("parameters");
      var2.a("count", zase.y(var3));
      ConnectionParameter var4 = null;

      for(int var5 = 0; var5 < var3; ++var5) {
         var4 = var1.get(var5);
         var2.b("parameter");
         if (var4.getSqlType() != 0) {
            int var6 = zuo.g(var4.getSqlType());
            var2.a("sqlType", zase.y(var6));
         }

         if (var4.getRefreshOnChange()) {
            var2.a("refreshOnChange", "1");
         }

         if (!this.a(var4.getName())) {
            var2.a("name", var4.getName());
         }

         if (!this.a(var4.getPrompt())) {
            var2.a("prompt", var4.getPrompt());
         }

         var2.a("parameterType", zuo.j(var4.getType()));
         if (!this.a(var4.getCellReference())) {
            var2.a("cell", var4.getCellReference());
         }

         if (var4.getValue() instanceof Boolean) {
            if ((Boolean)var4.getValue()) {
               var2.a("boolean", "1");
            } else {
               var2.a("boolean", "0");
            }
         } else if (var4.getValue() instanceof Double) {
            var2.a("double", zase.b((Double)var4.getValue()));
         } else if (var4.getValue() instanceof Integer) {
            var2.a("integer", zase.y((Integer)var4.getValue()));
         } else if (var4.getValue() instanceof String) {
            var2.a("string", (String)var4.getValue());
         }

         var2.b();
      }

      var2.b();
   }

   private boolean a(String var1) {
      return null == var1 || "".equals(var1);
   }
}
